package test03;

import sun.net.httpserver.AuthFilter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/register1.do")
public class RegisterServlet extends HttpServlet{
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        resp.setContentType("text/html; charset=UTF-8");
        StringBuffer requestURL = req.getRequestURL();
        String username = req.getParameter("username");
        String password = req.getParameter("password");

        resp.getWriter().println("登陆成功");
    }
}
//        if (username.length() == 0 && password.length() == 0) {
//            resp.getWriter().println("注册失败，用户名及密码均为空");
//        }
//        if (username.length() != 0 && password.length() == 0) {
//            resp.getWriter().println("注册失败，密码为空");
//        }
//        if (username.length() == 0 && password.length() != 0) {
//            resp.getWriter().println("注册失败，用户名为空");
//        }
//        if (username.length() != 0 && password.length() != 0) {
//            resp.getWriter().println("用户名：" + username);
//            resp.getWriter().println("<br>");
//            resp.getWriter().println("密码：" + password);
//            resp.getWriter().println("<br>");
//            resp.getWriter().println("注册成功");
//        }
//        if(req.getParameter("username").length()!=0){
//            resp.sendRedirect("/success.html");
//        }
//        //转发
//        req.setCharacterEncoding("UTF-8");
//        if(req.getParameter("username").length()==0){
//            req.getRequestDispatcher("/error.html").forward(req,resp);
//        }
//    }
//}
